/**
 * 
 */
package com.mycompany.project.client;

import com.google.gwt.event.shared.GwtEvent;

/**
 * @author Laboratorio Tv Collaborativa/Contenuti Digitali --> Sardegna District --> Crs4 --> Sardegna Ricerche
 * 
 * This class extends a GwtEvent class and implements @SaStria custom event and i particular mode the 
 * onAnnotationMoved event. This onAnnotationMoved event should be occurs when a user move
 * an annotation on video player by @SaStria tools interface. This class is responsible for generate and
 * dispatch the onAnnotationMoved event. 
 * 
 *       
 */
public class SaStriaCustomEvent extends GwtEvent<SaStriaCustomEventHandler> {
	public static Type<SaStriaCustomEventHandler> TYPE=new Type<SaStriaCustomEventHandler>();
	private NextActiveTag newLeftAndPlayPosition; 
	int annotationPreviewIndex; // index of annotation in previews panel list.
	private double timeEnd;    // annotation video segment end time. 
	private double timeStart;  // annotation video segment start time.

	
	/**
	 * Constructor of SaStriaCustomEvent that create an object of this class and initializes
	 * the newLeftAndPlayPosition element to the information about the annotation tag element
	 * moved that generates the onAnnotationMoved event.  
	 * @param lAndP  : NextActiveTag element containing the information about the annotation tag element
	 * moved that generates the onAnnotationMoved event. This parameter contain the index of the element
	 * in the annotation array list and the start time of annotation tag in video play.
	 */
	public SaStriaCustomEvent(NextActiveTag lAndP,int previewIndex,double timeS,double timeE) {
		newLeftAndPlayPosition=lAndP;
		annotationPreviewIndex=previewIndex;
		timeEnd=timeE;
		timeStart=timeS;
	}

	/**
	 * This method return the system parameter TYPE. Type class is used to register events with the HandlerManager.
	 * Type is parameterized by the handler type in order to make the addHandler method type safe.
	 */
	@Override
	public com.google.gwt.event.shared.GwtEvent.Type<SaStriaCustomEventHandler> getAssociatedType() {
		return TYPE;
	}

	/**
	 * This method run and dispatch the onAnnotationMoved event.
	 * @param handler: handler of SaStriaCustomEventHandler. 
	 */
	@Override
	protected void dispatch(SaStriaCustomEventHandler handler) {
		handler.onAnnotationMoved(this,newLeftAndPlayPosition);
	}

	
	/**
	 * Gets annotation index in previews panel list.
	 * @return
	 */
	public int getAnnotationPreviewIndex(){
		return(annotationPreviewIndex);
	}
	
	
	/**
	 * Sets annotation video segment end time.
	 * @param timeValue double value indicating annotation video segment end time.
	 */
	public void setTimeEnd(double timeValue){
		timeEnd=timeValue;
	}
	
	/**
	 * Gets annotation video segment Start time.
	 * @return timeValue double value indicating annotation video segment start time.
	 * 
	 */
	public double getTimeStart(){
		return(timeStart);
	}
	
	/**
	 * Gets annotation video segment end time.
	 * @return timeValue double value indicating annotation video segment end time.
	 */
	public double getTimeEnd(){
		return(timeEnd);
	}
	/**
	 * Sets annotation video segment start time.
	 * @param timeValue double value indicating annotation video segment end time.
	 */
	public void setTimeStart(double timeValue){
	timeStart=timeValue;
	}
	
	/**
	 * Sets annotation video segment start and end time.
	 * @param timeValueStart
	 * @param timeValueEnd
	 */
	public void setTimesegment(double timeValueStart,double timeValueEnd){
		setTimeStart(timeValueStart);
		setTimeEnd(timeValueEnd);
	}
	
	
}
